package org.bsscheduler;

/**
 *
 * @author tblackstone
 */
public class User {

    private boolean loggedIn = false;

    private String firstName;
    private String lastName;
    private String email;

    private String sessionDate;

    public EventList events;

    public User() { }

    @Override
    protected void finalize() throws Throwable {
        if(loggedIn) {
            UserManager.removeUser(this);
        }
        super.finalize();
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    public String getLastName() {
        return lastName;
    }

    public void setLastName(String lastName) {
        this.lastName = lastName;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public boolean getLoggedIn() {
        return loggedIn;
    }

    public void setLoggedIn(boolean isLoggedIn) {
        loggedIn = isLoggedIn;
    }

    public void loadEvents() {
        if (email == null) return;

        events = EventsDB.getEvents(email);

    }
    
    public void logout() {
        loggedIn = false;
        UserManager.removeUser(this);
        setEmail(null);
        setFirstName(null);
        setLastName(null);
        events = null;
    }

    public String getCurrentDate(){
        return sessionDate;
    }


    public void setCurrentDate(String myCurrentDate){
        sessionDate = myCurrentDate;
    }

}
